package com.lw.leetcode.node;

/**
 * 404. 左叶子之和
 *
 * @Author liw
 * @Date 2021/5/8 13:33
 * @Version 1.0
 */
public class SumOfLeftLeaves {

    public int sumOfLeftLeaves(TreeNode root) {
        if (root == null) {
            return 0;
        }
        if (root.left != null && root.left.left == null && root.left.right == null) {
            return root.left.val + sumOfLeftLeaves(root.right);
        }
        return sumOfLeftLeaves(root.left) + sumOfLeftLeaves(root.right);
    }

}
